package com.jftone.bh.app.util;

import org.apache.commons.codec.digest.DigestUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 验证数据类型
 */
public class DataUtil {
    public static final String MD_SIGN ="biaohong";

    public static boolean isPhone(String phone) {
//        String regex = "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9]))\\d{8}$";
        String regex = "^1\\d{10}$";
        if (phone.length() != 11) {
            return false;
        } else {
            Pattern p = Pattern.compile(regex);
            Matcher m = p.matcher(phone);
            boolean isMatch = m.matches();
            return isMatch;
        }
    }

    public static String switchPwd(String password){

        if(password!=null){
            String md5pwd = DigestUtils.md5Hex(password);
            return md5pwd;
        }

        return null;

    }

}
